package com.hgvip.controller;

import com.alibaba.fastjson.JSON;
import com.hgvip.common.entity.ResponseData;
import com.hgvip.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * Created by arnold.zhu on 6/26/2017.
 */
@RestController
@RequestMapping("/user")
public class UserController {

    private Logger logger = LoggerFactory.getLogger(UserController.class);

    @RequestMapping(value = "/addUser", method = RequestMethod.GET)
    public Object addUser() {
        String[] names = {"Jack", "Tom", "John", "Arnold", "Jim", "James", "Rock"};
        String[] introduce = {"I like to collect rock albums", "I like to build cabinets",
                "I like playing computer games", "I like climbing mountains", "I love running",
                "I love eating", "I love drinking"};
        for (int i = 0; i < 1000; i++) {
            Random random = new Random();
            int tempNum = random.nextInt(7);
            User user = new User();
            user.setId(i);
            user.setAge(random.nextInt(20) + 20);
            user.setIntroduce(introduce[tempNum]);
            user.setName(names[tempNum] + i);
            logger.info(JSON.toJSONString(user));
        }
        return new ResponseData(200, "Success");
    }

}
